package com.example.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.entity.Student;
import com.example.mapper.StudentMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 学生表 前端控制器
 * </p>
 *
 * @author fanbinbing
 * @since 2021-11-30
 */
@Api(value = "学生数据test",tags = "学生数据接口API")
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentMapper studentMapper;
    @GetMapping("/selectForPage")
    @ApiOperation(value = "用户查询接口",notes = "分页查询数据",httpMethod = "GET", response = Map.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "页数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "size",value = "总数",paramType = "query",dataType = "String",required = false)
    })
    public Map<String,Object> selectForPage(Integer page,Integer size){
        Page<Student> page1 = new Page<>(page,size);
        IPage<Student> studentIPage = studentMapper.selectPage(page1, null);
        Map<String, Object> map = new HashMap<>();
        map.put("code",200);
        map.put("msg","查询成功");
        map.put("data",studentIPage);
        return map;
    }
}

